package bai1;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Example {
	public static void inputInt(){
		Scanner ip=new Scanner(System.in);
		System.out.println("Nhap gia tri can nhap:");
		try{
			int a=ip.nextInt();
		System.out.println("Gia tri vua nhap la: "+a);
		}
		catch(InputMismatchException e){
			System.out.println("Gia tri nhap vao khong dung dinh dang");
		}
	}
	public static void inputFloat(){
		Scanner ip=new Scanner(System.in);
		System.out.println("Nhap gia tri can nhap:");
		try{
		float b=ip.nextFloat();
		System.out.println("Gia tri vua nhap la"+b);
		}catch(InputMismatchException e){
			System.out.println("Nhap khong dung dinh dang");
		}
	}
	public void inputChar(){
		Scanner ip=new Scanner(System.in);
		System.out.println("Nhap gia tri can nhap:");
		
	}
	public static void inputString(){
		Scanner ip=new Scanner(System.in);
		System.out.println("Nhap gia tri can nhap:");
		String d=ip.nextLine();
		if(d.trim().equals("")){
			System.out.println("Chua nhap gia tri");
		}else{
		try{
		System.out.println("Gia tri vua nhap vao la :"+d);
		}catch(InputMismatchException e){
			System.out.println("Nhap khong dung dinh dang");
		}}
	}
	public static void main(String args[]){
		Scanner ip=new Scanner(System.in);
		int chon=1;
		do{
		System.out.println("====================Menu====================");
		System.out.println("1) Nhap vao bien so gia tri int");
		System.out.println("2) Nhap vao bien so gia tri float");
		System.out.println("3) Nhap vao bien so gia tri char");
		System.out.println("4) Nhap vao bien so gia tri string");
		System.out.println("5) Thoat chuong trinh");
		try{
			chon=ip.nextInt();
		}catch(InputMismatchException e){
			System.out.println("Nhap sai dinh dang");
		}
		switch(chon){
		case 1:{
			inputInt();
			break;
		}
		case 2:{
			inputFloat();
			break;
		}
		case 3:{
			break;
		}
		case 4:{
			inputString();
			break;
		}case 5:{
			break;
		}
		default:
			System.out.println("Nhap sai vui long nhap lai");
		}
	}
	while(chon!=0);

}
}